#!/usr/bin/env ruby
require 'erb'

require 'session'

TMPL = <<EOF
class <%= class_name.snake_case.camel_case %> < Pan::Component
  def initialize()

  end

  def render_on(html)

  end
end
EOF

if ARGV.size == 0
  puts 'usage new_component MyNewComponent or my_new_component'
  exit -1
end

class_name = ARGV[0]
filename = format(Dir.pwd+"/app/%s.rb", class_name.snake_case)
if File.exists?(filename)
  puts "file already exists! bailing out..."
  exit -1
else
  File.open(filename, 'w+') do |file|
    file.write ERB.new(TMPL).result(binding)
  end
  puts "#{filename} created"
end
